// 发送请求用户信息
getUserInfo()
function getUserInfo() {
  axios
    .get("/my/userinfo", {
      // headers: {
      // Authorization: localStorage.getItem("token"),
      // },
    })
    .then(({ data: { data, status, message } }) => {
      // console.log(data , status , message);
      // 判断下status message , 看是否认证失败 ==> 去登陆界面 
      // 限制用户权限

      let name = data.nickname || data.username;
      // return 
      if (data.user_pic) {
        $('.avatar').attr('src', data.user_pic).show()
        $(".text-avatar-box").hide();
      } else {
        $(".text-avatar-box").show()
        $('.text-avatar').text(name[0].toUpperCase())
        $('.avatar').hide()
      }
      $('#welcome').html('欢迎' + name)
    })
}

//todo 退出功能 
const layer = layui.layer
$('#btnLogout').click(function () {
  layer.confirm('确认退出登陆吗?', { icon: 3, title: '提示' }, function (index) {
    layer.close(index);
    localStorage.removeItem('token')
    location.href = '/login.html'
  });
})